public class MyCircularQueue {
    int[] queue;
    int first=0;
    int end=0;
    MyCircularQueue(int k){
        queue=new int[k+1];
    }
    public int Front(){
        if(isEmpty()){
            return -1;
        }
        return queue[first];
    }
    public int Rear(){
        if (isEmpty()) {
            return -1;
        }
        if (end==0){
            return queue[queue.length-1];
        }else {
            return queue[end-1];
        }
    }
    public Boolean enQueue( int value){
        if(isFull()){
            return false;
        }
        queue[end]=value;
        end=(end+1)%queue.length;
        return true;
    }
    public Boolean deQueue(){
        if(isEmpty()){
            return false;
        }
        first=(first+1)%queue.length;
        return true;
    }
    public Boolean isEmpty(){
        if(first==end){
            return true;
        }else {return false;}
    }
    public Boolean isFull(){
        if((end+1)%queue.length==first){
            return true;
        } else {
            return false;
        }
    }


}
